package scripts.jobQueue.script 
{
    import com.umge.sovt.client.response.*;
    import com.umge.sovt.common.*;
    import com.umge.sovt.common.beans.*;
    import com.umge.sovt.common.constants.*;
    import com.umge.sovt.common.server.events.*;
    
    import flash.events.*;
    import flash.utils.*;
    
    import mx.events.*;
    

    
    public class Context extends Object implements flash.events.IEventDispatcher
    {
	   	public static const EVENT_PLAYER_LOGIN:String="Context.login";
	    public static const EVENT_CASTLE_CHANGE:String="Context.curCastleChange";
	    public static const EVENT_CASTLE_MOVE:String="Context.curCastleMove";
	    public static const INNER_BUILDING_POSITION:int=100;
	    public var army_RedCount:uint;
	    private var timeDiff:Number;
	    private var _779961972serverHours:int;
	    public var army_BlueCount:uint;
	    private var _2040226844serverMinutes:int;
	    private var loginDateTime:Date;
	    private var LoginPrestigeValue:int=-1;
	    private var _bindingEventDispatcher:flash.events.EventDispatcher;
	    public var isLink:Boolean;
	    public var userIsFirstLogin:Boolean=false;
	    private var _1826408047serverDate:int;
	    public var blueCount:uint;
	    private var curCastle:CastleBean;
	    private var player:PlayerBean;
	    private var _1825779168serverYear:int;
	    private var _775351043serverMonth:int;
	    public var userName:String="";
	    private var myTimer:flash.utils.Timer;
	    public static var gameSpeed:int=1;
	    private static var instance:Context;
	    public static var mapSizeX:int=800;
	    public static var mapSizeY:int=800;
	    
	    
        public function Context()
        {
            _bindingEventDispatcher = new flash.events.EventDispatcher(flash.events.IEventDispatcher(this));
            super();
            //ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_BUILD_COMPLATE, onBuildComplete);
            //ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_HERO_UPDATE, onHeroUpdate);
            ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_RESOURCE_UPDATE, onResourceUpdate);
            ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_PLAYER_INFO_UPDATE, onPlayerInfoUpdate);
            //ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_ITEM_UPDATE, onItemUpdate);
            //ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_SELF_ARMYS_UPDATE, onSelfArmysUpdate);
            //ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_ENEMY_ARMYS_UPDATE, onEnemyArmysUpdate);
            //ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_FRIEND_ARMYS_UPDATE, onFriendArmysUpdate);
            ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_TROOP_UPDATE, onTroopUpdate);
            ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_FORTIFICATIONS_UPDATE, onFortiFicationsUpdate);
            //ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_CASTLE_FIELD_UPDATE, onCastleFieldUpdate);
            //ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_TRADES_UPDATE, onTradesUpdate);
            //ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_TRANSING_TRADE_UPDATE, onTransingTradeUpdate);
            ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_NEW_MAIL, onNewMail);
            ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_NEW_REPORT, onNewReport);
            //ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_NEW_FINISHED_QUEST, onNewFinishedQuest);
            
            //ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_PLAYER_BUFF_UPDATE, onPlayerBuffUpdate);
            //ResponseDispatcher.getInstance().addEventListener(ResponseDispatcher.SERVER_CASTLE_UPDATE, onCastleUpdate); 
            return;
        }

        public function willTrigger(arg1:String):Boolean
        {
            return _bindingEventDispatcher.willTrigger(arg1);
        }

        public function get serverHours():int
        {
            return this._779961972serverHours;
        }

        public function get serverDate():int
        {
            return this._1826408047serverDate;
        }
		
		private function onNewMail(arg1:NewMail):void
		{
			this.player.newMaileCount_inbox = arg1.count_inbox;
			this.player.newMaileCount_system = arg1.count_system;
			this.player.newMailCount = arg1.count;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "NewMail", null, arg1));			
		}
		
		private function onNewReport(arg1:NewReport):void
		{
			this.player.newReportCount_army = arg1.army_count
			this.player.newReportCount_trade = arg1.trade_count
			this.player.newReportCount_other = arg1.other_count
			this.player.newReportCount = arg1.count;
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "NewReport", null, arg1));
		}
		
/* 		private function onNewFinishedQuest(arg1:NewFinishedQuest):void
		{
            ActionFactory.getInstance().getQuestCommands().getQuestType(com.umge.civony.Context.getInstance().getCurCastle().id, 1);
            ActionFactory.getInstance().getQuestCommands().getQuestType(com.umge.civony.Context.getInstance().getCurCastle().id, 3);
		} */
		
/*         private function onSelfArmysUpdate(arg1:SelfArmysUpdate):void
        {
            com.umge.sovt.common.CommonUtil.arrayCopy(arg1.armysArray, player.selfArmysArray);
            return;
        } */

        public function set serverHours(arg1:int):void
        {
            var loc1:*;
            loc1 = this._779961972serverHours;
            if (loc1 !== arg1)
            {
                this._779961972serverHours = arg1;
                this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "serverHours", loc1, arg1));
            }
            return;
        }

        public function get serverYear():int
        {
            return this._1825779168serverYear;
        }

        private function onHeroUpdate(arg1:HeroUpdate):void
        {
            var loc2:*;
            loc2 = 0;
            var loc3:*;
            loc3 = null;
            trace("Context.onHeroUpdate.");
            var loc1:*;
            loc1 = this.getCastleById(arg1.castleId);
            if (loc1 != null)
            {
                if (arg1.updateType != CommonConstants.UPDATE_TYPE_ADD)
                {
                    loc2 = 0;
                    while (loc2 < loc1.herosArray.length) 
                    {
                        if ((loc3 = loc1.getHeros(loc2)).id == arg1.hero.id)
                        {
                            if (arg1.updateType != CommonConstants.UPDATE_TYPE_UPDATE)
                            {
                                loc1.herosArray.removeItemAt(loc2);
                            }
                            else 
                            {
                                arg1.hero.copyTo(loc1.herosArray[loc2]);
                            }
                            return;
                        }
                        ++loc2;
                    }
                }
                else 
                {
                    loc1.herosArray.addItem(arg1.hero);
                }
            }
            return;
        }

        public function get serverMinutes():int
        {
            return this._2040226844serverMinutes;
        }

        public function Player():PlayerBean
        {
            return this.player;
        }

        /* private function onBuildComplete(arg1:com.umge.sovt.common.server.events.BuildComplate):void
        {
            var loc2:*;
            loc2 = false;
            var loc3:*;
            loc3 = 0;
            var loc4:*;
            loc4 = null;
            trace("Context.onBuildComplete.");
            var loc1:*;
            loc1 = getCastleById(arg1.castleId);
            if (loc1 != null)
            {
                loc2 = false;
                loc3 = 0;
                while (loc3 < loc1.buildingsArray.length) 
                {
                    if ((loc4 = loc1.getBuildings(loc3)).positionId == arg1.buildingBean.positionId)
                    {
                        if (com.umge.civony.util.UIUtil.isBuildingDestroy(arg1.buildingBean))
                        {
                            trace("Context.onBuildComplete():castleId=" + loc1.id + " delete from array id=" + loc3);
                            loc1.buildingsArray.removeItemAt(loc3);
                            if (com.umge.civony.util.UIUtil.isInnerBuilding(arg1.buildingBean))
                            {
                                com.umge.civony.MsgDispacther.getInstance().dispatchEvent(new com.umge.civony.events.BuildingChangeEvent(view.castle.CastleIn.EVENT_BUILDING_DESTROY, arg1.buildingBean));
                            }
                            else 
                            {
                                com.umge.civony.MsgDispacther.getInstance().dispatchEvent(new com.umge.civony.events.BuildingChangeEvent(view.castle.CastleOut.EVENT_BUILDING_DESTROY, arg1.buildingBean));
                            }
                        }
                        else 
                        {
                            trace("Context.onBuildComplete():castleId=" + loc1.id + " update buildingBean to Array, ArrayId=" + loc3);
                            arg1.buildingBean.copyTo(loc1.buildingsArray[loc3]);
                        }
                        loc2 = true;
                    }
                    ++loc3;
                }
                if (!loc2)
                {
                    this.curCastle.buildingsArray.addItem(arg1.buildingBean);
                    if (com.umge.civony.util.UIUtil.isInnerBuilding(arg1.buildingBean))
                    {
                        com.umge.civony.MsgDispacther.getInstance().dispatchEvent(new com.umge.civony.events.BuildingChangeEvent(view.castle.CastleIn.EVENT_BUILDING_CREATED, arg1.buildingBean));
                    }
                    else 
                    {
                        com.umge.civony.MsgDispacther.getInstance().dispatchEvent(new com.umge.civony.events.BuildingChangeEvent(view.castle.CastleOut.EVENT_BUILDING_CREATED, arg1.buildingBean));
                    }
                }
                view.castle.BottomToolBar.buildingUpdate(arg1);
            }
            return;
        } */

/*         private function onCastleFieldUpdate(arg1:CastleFieldUpdate):void
        {
            var loc2:*;
            loc2 = 0;
            var loc3:*;
            loc3 = null;
            var loc1:*;
            loc1 = this.getCastleById(arg1.castleId);
            if (loc1 != null)
            {
                if (arg1.updateType != CommonConstants.UPDATE_TYPE_ADD)
                {
                    loc2 = 0;
                    while (loc2 < loc1.fieldsArray.length) 
                    {
                        if ((loc3 = loc1.fieldsArray[loc2] as FieldBean).id == arg1.bean.id)
                        {
                            if (arg1.updateType != CommonConstants.UPDATE_TYPE_DELETE)
                            {
                                arg1.bean.copyTo(loc3);
                            }
                            else 
                            {
                                loc1.fieldsArray.removeItemAt(loc2);
                            }
                        }
                        ++loc2;
                    }
                }
                else 
                {
                    loc1.fieldsArray.addItem(arg1.bean);
                }
            }
            return;
        } */

        private function onFortiFicationsUpdate(arg1:FortificationsUpdate):void
        {
            var loc1:*;
            loc1 = this.getCastleById(arg1.castleId);
            if (loc1 != null)
            {
                arg1.fortification.copyTo(loc1.fortification);
                this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "FortificationsUpdate", loc1, arg1));
            }
            return;
        }

        public function set serverDate(arg1:int):void
        {
            var loc1:*;
            loc1 = this._1826408047serverDate;
            if (loc1 !== arg1)
            {
                this._1826408047serverDate = arg1;
                this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "serverDate", loc1, arg1));
            }
            return;
        }

        private function onResourceUpdate(arg1:ResourceUpdate):void
        {
            trace("Context.onResourceUpdate.");
            var loc1:*;
            loc1 = this.getCastleById(arg1.castleId);
            if (loc1 != null)
            {
                arg1.resource.copyTo(loc1.resource);
                this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "ResourceUpdate", loc1, arg1));
            }
            return;
        }

/*         private function onTradesUpdate(arg1:TradesUpdate):void
        {
            var loc2:*;
            loc2 = 0;
            var loc3:*;
            loc3 = null;
            var loc1:*;
            loc1 = this.getCastleById(arg1.castleId);
            if (loc1 != null)
            {
                if (arg1.updateType != CommonConstants.UPDATE_TYPE_ADD)
                {
                    loc2 = 0;
                    while (loc2 < loc1.tradesArray.length) 
                    {
                        if ((loc3 = loc1.tradesArray[loc2] as TradeBean).id == arg1.tradeBean.id)
                        {
                            if (arg1.updateType != CommonConstants.UPDATE_TYPE_DELETE)
                            {
                                arg1.tradeBean.copyTo(loc3);
                            }
                            else 
                            {
                                loc1.tradesArray.removeItemAt(loc2);
                            }
                        }
                        ++loc2;
                    }
                }
                else 
                {
                    loc1.tradesArray.addItem(arg1.tradeBean);
                }
            }
            return;
        } */

        public function set serverMinutes(arg1:int):void
        {
            var loc1:*;
            loc1 = this._2040226844serverMinutes;
            if (loc1 !== arg1)
            {
                this._2040226844serverMinutes = arg1;
                this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "serverMinutes", loc1, arg1));
            }
            return;
        }

        public function setPlayerBean(arg1:PlayerBean):void
        {
            mapSizeX = arg1.mapSizeX;
            mapSizeY = arg1.mapSizeY;
            trace("Context.setPlayerBean()");
            this.player = arg1;
            if (myTimer == null)
            {
                myTimer = new flash.utils.Timer(1000, 0);
                myTimer.addEventListener(flash.events.TimerEvent.TIMER, timerHandler);
                myTimer.start();
            }
            var loc1:*;
            loc1 = new Date();
            this.timeDiff = loc1.valueOf() - arg1.currentTime;
            this.loginDateTime = loc1;
            return;
        }

/*         private function onPlayerBuffUpdate(arg1:com.umge.sovt.common.server.events.PlayerBuffUpdate):void
        {
            var loc1:*;
            loc1 = 0;
            var loc2:*;
            loc2 = null;
            if (arg1.updateType != com.umge.sovt.common.constants.CommonConstants.UPDATE_TYPE_ADD)
            {
                loc1 = 0;
                while (loc1 < this.player.buffsArray.length) 
                {
                    loc2 = this.player.buffsArray[loc1] as com.umge.sovt.common.beans.BuffBean;
                    if (loc2.typeId == arg1.buffBean.typeId)
                    {
                        if (arg1.updateType != com.umge.sovt.common.constants.CommonConstants.UPDATE_TYPE_DELETE)
                        {
                            arg1.buffBean.copyTo(loc2);
                        }
                        else 
                        {
                            this.player.buffsArray.removeItemAt(loc1);
                        }
                    }
                    ++loc1;
                }
            }
            else 
            {
                this.player.buffsArray.addItem(arg1.buffBean);
            }
            com.umge.civony.factory.BuffManager.sortBuffArray(this.player.buffsArray);
            return;
        }
 */
/*         private function onEnemyArmysUpdate(arg1:EnemyArmysUpdate):void
        {
            com.umge.sovt.common.CommonUtil.arrayCopy(arg1.armysArray, player.enemyArmysArray);
            return;
        } */

        public function set serverYear(arg1:int):void
        {
            var loc1:*;
            loc1 = this._1825779168serverYear;
            if (loc1 !== arg1)
            {
                this._1825779168serverYear = arg1;
                this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "serverYear", loc1, arg1));
            }
            return;
        }

        private function timerHandler(arg1:flash.events.TimerEvent):void
        {
            var loc6:*;
            loc6 = null;
            var loc7:*;
            loc7 = null;
            var loc1:*;
            loc1 = this.player.currentDateTime.toString().split(" ");
            var loc2:*;
            loc2 = loc1[0].toString().split(".");
            var loc3:*;
            loc3 = loc1[1].toString().split(".");
            var loc4:*;
            loc4 = new Date(loc2[0], (loc2[1] - 1), loc2[2], loc3[0], loc3[1], loc3[2]);
            var loc5:*;
            loc5 = new Date(loc4.valueOf() + new Date().valueOf() - this.loginDateTime.valueOf());
            serverHours = loc5.getHours();
            serverMinutes = loc5.getMinutes();
            serverYear = loc5.getFullYear();
            serverMonth = loc5.getMonth() + 1;
            serverDate = loc5.getDate();
            var loc8:*;
            loc8 = 0;
            var loc9:*;
            loc9 = this.player.castlesArray;
            for each (loc6 in loc9)
            {
                if ((loc7 = loc6.resource).food.amount < loc7.food.max)
                {
                    loc7.food.amount = loc7.food.amount + (loc7.food.increaseRate - loc7.troopCostFood) / 3600;
                    if (loc7.food.amount < 0)
                    {
                        loc7.food.amount = 0;
                    }
                }
                else 
                {
                    if ((loc7.food.increaseRate - loc7.troopCostFood) / 3600 < 0)
                    {
                        loc7.food.amount = loc7.food.amount + (loc7.food.increaseRate - loc7.troopCostFood) / 3600;
                    }
                }
                if (loc7.wood.amount < loc7.wood.max)
                {
                    loc7.wood.amount = loc7.wood.amount + loc7.wood.increaseRate / 3600;
                    if (loc7.wood.amount < 0)
                    {
                        loc7.wood.amount = 0;
                    }
                }
                if (loc7.stone.amount < loc7.stone.max)
                {
                    loc7.stone.amount = loc7.stone.amount + loc7.stone.increaseRate / 3600;
                    if (loc7.stone.amount < 0)
                    {
                        loc7.stone.amount = 0;
                    }
                }
                if (!(loc7.iron.amount < loc7.iron.max))
                {
                    continue;
                }
                loc7.iron.amount = loc7.iron.amount + loc7.iron.increaseRate / 3600;
                if (!(loc7.iron.amount < 0))
                {
                    continue;
                }
                loc7.iron.amount = 0;
            }
			this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "timerUpdate", null, serverMinutes));           
            return;
        }

        public function dispatchEvent(arg1:flash.events.Event):Boolean
        {
            return _bindingEventDispatcher.dispatchEvent(arg1);
        }

        public function addEventListener(arg1:String, arg2:Function, arg3:Boolean=false, arg4:int=0, arg5:Boolean=false):void
        {
            _bindingEventDispatcher.addEventListener(arg1, arg2, arg3, arg4, arg5);
            return;
        }

/*         private function onFriendArmysUpdate(arg1:FriendArmysUpdate):void
        {
            com.umge.sovt.common.CommonUtil.arrayCopy(arg1.armysArray, player.friendArmysArray);
            return;
        } */

/*         private function onTransingTradeUpdate(arg1:TransingTradeUpdate):void
        {
            var loc2:*;
            loc2 = 0;
            var loc3:*;
            loc3 = null;
            var loc1:*;
            loc1 = this.getCastleById(arg1.castleId);
            if (loc1 != null)
            {
                if (arg1.updateType != CommonConstants.UPDATE_TYPE_ADD)
                {
                    loc2 = 0;
                    while (loc2 < loc1.transingTradesArray.length) 
                    {
                        if ((loc3 = loc1.transingTradesArray[loc2] as TransingTradeBean).id == arg1.bean.id)
                        {
                            if (arg1.updateType != CommonConstants.UPDATE_TYPE_DELETE)
                            {
                                arg1.bean.copyTo(loc3);
                            }
                            else 
                            {
                                loc1.transingTradesArray.removeItemAt(loc2);
                            }
                        }
                        ++loc2;
                    }
                }
                else 
                {
                    loc1.transingTradesArray.addItem(arg1.bean);
                }
            }
            return;
        } */

        private function onPlayerInfoUpdate(arg1:PlayerInfoUpdate):void
        {
            arg1.playerInfo.copyTo(this.player.playerInfo);
            if (this.LoginPrestigeValue != -1)
            {
                if (this.LoginPrestigeValue < 100)
                {
                    if (this.player.playerInfo.prestige >= 100)
                    {
                        this.LoginPrestigeValue = this.player.playerInfo.prestige;
                    }
                }
            }
            else 
            {
                this.LoginPrestigeValue = this.player.playerInfo.prestige;
            }
            this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "PlayerInfoUpdate", null, arg1));
            return;
        }

        public function removeEventListener(arg1:String, arg2:Function, arg3:Boolean=false):void
        {
            _bindingEventDispatcher.removeEventListener(arg1, arg2, arg3);
            return;
        }

        private function onTroopUpdate(arg1:TroopUpdate):void
        {
            var loc1:*;
            loc1 = this.getCastleById(arg1.caslteId);
            if (loc1 != null)
            {
                arg1.troop.copyTo(loc1.troop);
                this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "TroopUpdate", loc1, arg1));                
            }
            return;
        }

/*         private function onCastleUpdate(arg1:com.umge.sovt.common.server.events.CastleUpdate):void
        {
            var loc1:*;
            loc1 = 0;
            var loc2:*;
            loc2 = null;
            trace("event.updateType-----------------:" + arg1.updateType);
            if (arg1.updateType != com.umge.sovt.common.constants.CommonConstants.UPDATE_TYPE_ADD)
            {
                loc1 = 0;
                while (loc1 < this.player.castlesArray.length) 
                {
                    loc2 = this.player.castlesArray[loc1] as com.umge.sovt.common.beans.CastleBean;
                    if (loc2.id == arg1.castleBean.id)
                    {
                        if (arg1.updateType != com.umge.sovt.common.constants.CommonConstants.UPDATE_TYPE_DELETE)
                        {
                            loc2.fieldId = arg1.castleBean.fieldId;
                        }
                        else 
                        {
                            if (arg1.updateType != com.umge.sovt.common.constants.CommonConstants.UPDATE_TYPE_DELETE)
                            {
                                loc2.fieldId = arg1.castleBean.fieldId;
                            }
                            else 
                            {
                                this.player.castlesArray.removeItemAt(loc1);
                            }
                        }
                    }
                    ++loc1;
                }
            }
            else 
            {
                this.player.castlesArray.addItem(arg1.castleBean);
            }
            return;
        }
 */
        public function getTimeDiff():Number
        {
            return this.timeDiff;
        }

        public function getCastleById(arg1:int):CastleBean
        {
            var loc1:*;
            loc1 = null;
            var loc2:*;
            loc2 = 0;
            var loc3:*;
            loc3 = player.castlesArray;
            for each (loc1 in loc3)
            {
                if (loc1.id != arg1)
                {
                    continue;
                }
                return loc1;
            }
            return null;
        }

        public function hasEventListener(arg1:String):Boolean
        {
            return _bindingEventDispatcher.hasEventListener(arg1);
        }

        public function set serverMonth(arg1:int):void
        {
            var loc1:*;
            loc1 = this._775351043serverMonth;
            if (loc1 !== arg1)
            {
                this._775351043serverMonth = arg1;
                this.dispatchEvent(mx.events.PropertyChangeEvent.createUpdateEvent(this, "serverMonth", loc1, arg1));
            }
            return;
        }

/*         private function onItemUpdate(arg1:ItemUpdate):void
        {
            var loc2:*;
            loc2 = null;
            var loc3:*;
            loc3 = 0;
            var loc4:*;
            loc4 = null;
            var loc1:*;
            loc1 = false;
            var loc5:*;
            loc5 = 0;
            var loc6:*;
            loc6 = arg1.itemsArray;
            for each (loc2 in loc6)
            {
                loc1 = false;
                loc3 = 0;
                while (loc3 < player.itemsArray.length) 
                {
                    if ((loc4 = player.itemsArray[loc3]).id == loc2.id)
                    {
                        loc1 = true;
                        loc4.count = loc2.count;
                    }
                    ++loc3;
                }
                if (loc1)
                {
                    continue;
                }
                player.itemsArray.addItem(loc2);
            }
            return;
        } */

        public function get serverMonth():int
        {
            return this._775351043serverMonth;
        }

        public static function getInstance():Context
        {
            return instance;
        }

        
        {
            instance = new Context();
            mapSizeX = 800;
            mapSizeY = 800;
            gameSpeed = 1;
        }


    }
}
